/* -----------------------------------------------------------------------
 * Demonstration of how to write unit tests for dominion-base
 * Include the following lines in your makefile:
 *
 * unittest2: unittest2.c dominion.o rngs.o
 *      gcc -o testUpdateCoins -g  unittest2.c dominion.o rngs.o $(CFLAGS)
 * -----------------------------------------------------------------------
 */

#include "dominion.h"
#include "dominion_helpers.h"
#include <string.h>
#include <stdio.h>
#include <assert.h>
#include "rngs.h"

int main() {
	//testing great hall card
	struct gameState G;
	int numPlayer = 2;
	int seed = 2;
	int player = 0;//just player 0 for now
	int k[10] = {adventurer, council_room, feast, gardens, mine
		, remodel, smithy, village, baron, great_hall};
	
	

	
	
	///////////////////////////////////////////////////////////////////////////////////////////////////////
	initializeGame(numPlayer, k, seed, &G); // initialize a new game, deciding later if this is necessary
	int coin_bonus=0;
	int startingDeckCount = G.deckCount[player];
	int startingHandCount = G.handCount[player];
	int startingActionsCount = G.numActions;
	
	int handPos = 0;
	
	//this card should draw a card, which takes an action, but also return an action. In the end it should be a wash. (It's basically a placeholder
	//for a VP, but doesn't get in your way like an estate). All that should happen is deckCount goes down one, and one card goes into playedCardCount
	//though it says "discard" in the fxn, what it means is remove from playable hand. It does not go into the discard pile until another function tells it to.
	cardEffect(great_hall,0,0,0,&G,handPos,&coin_bonus);
	

	if ((G.deckCount[player]==(startingDeckCount-1)) && (G.handCount[player]==(startingHandCount))&&(G.playedCardCount == 1))  {
		printf("Passed basic card test\n");
	}
	else{
		printf("Failed basic card test\n");
	}
	///////////////////////////////////////////////////////////////////////////////////////////////////////

	
	
	
	
	
	//what happens if there are no cards to draw from in draw pile or discard pile?
	///////////////////////////////////////////////////////////////////////////////////////////////////////
	initializeGame(numPlayer, k, seed, &G); // initialize a new game, deciding later if this is necessary
	G.deckCount[player]=0;//remove cards from deck
	startingDeckCount = G.deckCount[player];
	startingHandCount = G.handCount[player];
	
	
	cardEffect(great_hall,0,0,0,&G,handPos,&coin_bonus);
	
	//no cards to draw, so should simply remove the card played, add to the played card count, and leave the deck count at zero
	if ((G.handCount[player] == (startingHandCount-1)) &&(G.playedCardCount == 1)&&(G.deckCount[player]==0)    ){ 
		printf("Passed no cards left test\n");
	}
	else{
		printf("Failed no cards left test\n");
	}
	///////////////////////////////////////////////////////////////////////////////////////////////////////
	
	
	
	
	
	
	
	//what happens if there are no cards to draw from in draw pile, but there are cards in the discard pile?
	///////////////////////////////////////////////////////////////////////////////////////////////////////
	initializeGame(numPlayer, k, seed, &G); // initialize a new game, deciding later if this is necessary
	G.deckCount[player]=0;//remove cards from deck
	G.discardCount[player]=10;
	startingDeckCount = G.deckCount[player];
	startingHandCount = G.handCount[player];
	
	cardEffect(great_hall,0,0,0,&G,handPos,&coin_bonus);
	
	//now we have cards in the discard pile, so hand count should decrement by one, playedCard increment by one, and all 10
	//of the discard pile should move into the deckCount, then be decremented by 3 to be 7
	if ((G.handCount[player] == (startingHandCount)) &&(G.playedCardCount ==1)&&(G.deckCount[player]==9) && (G.discardCount[player]==0)     ){ 
		printf("Passed reshuffle discarded cards into empty deck test\n");
	}
	else{
		printf("Failed reshuffle discarded cards into empty deck test\n");
	}
	///////////////////////////////////////////////////////////////////////////////////////////////////////

	return 0;
}
	
	
	//	printf("Deck count before cardEffect: %d\n", G.deckCount[player]);
	//	printf("Discard count before cardEffect: %d\n", G.discardCount[player]);
	//	printf("Played count before cardEffect: %d\n", G.playedCardCount);
	//	printf("Hand count before cardEffect: %d\n", G.handCount[player]);
	//	
	//	printf("Deck count after cardEffect: %d\n", G.deckCount[player]);
	//	printf("Discard count after cardEffect: %d\n", G.discardCount[player]);
	//	printf("Hand count after cardEffect: %d\n", G.handCount[player]);
	//	printf("Played count after cardEffect: %d\n", G.playedCardCount);